﻿using Microsoft.EntityFrameworkCore;
using Sgr.Data;

namespace Sgr.EntityFrameworkCore
{
    public class PostgreSqlDbContextConfigurator : IDbContextConfigurator
    {
        public void Configure(DbContextOptionsBuilder builder, string connectionString)
        {
            builder.UseNpgsql(connectionString,
                    optionsBuilder =>
                    {
                        optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
                        optionsBuilder
                            .MinBatchSize(1)
                            .MaxBatchSize(1000);
                    });
        }

        public bool IsSupported(DatabaseType dbType)
        {
            return dbType == DatabaseType.PostgreSql;
        }
    }
}